<?php
/**
 *
 */
class Sx_upload extends CI_Controller {

	public function index() {
		if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
			print($this -> fengchaoclass -> showhckmsg("","",$this -> lang -> line('hck_upload_postnull'), TRUE));
			
		} else {
			$data = $GLOBALS['HTTP_RAW_POST_DATA'];
			empty($data)?($data = file_get_contents('php://input')):$data;
			if (!empty($data) && isset($data)) {
				$now = date("YmdHis");
				$path = "upload/";
				
				if (!file_exists($path . $now . ".jpg")) {
					$fo = fopen($path . $now . ".jpg", "w");
					if (fwrite($fo, $data) === false) {
						print($this -> fengchaoclass -> showhckmsg("","",$this -> lang -> line('hck_upload_error'), TRUE));
					} else {
						$flag = $now . ".png";
						$myArr['Msg_error'] = "0";
						$myArr['Msg'] = "";
						$myArr['MsgTime'] = date("Y-m-d H:i:s");
						$myArr['UploadFile'] = base_url()."upload/".$flag;
						$this -> msgArr = $myArr;
						print_r(json_encode($this -> msgArr));
						exit ;
					}

				}
			} else {
				print($this -> fengchaoclass -> showhckmsg("","",$this -> lang -> line('hck_upload_postnull'), TRUE));
			}

		}
	}

}
?>